package com.fit.user.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class MyFilter implements Filter {
	private String encoding;
	@SuppressWarnings("unused")
	private FilterConfig config=null;
	public void destroy() {
		config=null;
	}

	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		if(!"ignore".equals(this.encoding)){
			request.setCharacterEncoding(encoding);
			response.setCharacterEncoding(encoding);
		}
		chain.doFilter(request, response);
			
		
	}

	public void init(FilterConfig config) throws ServletException {
		encoding=config.getInitParameter("encoding");
		this.config=config;
	}

}
